<<<<<<< HEAD
"""
插值方法：测量高程
"""

import numpy as np
from scipy import interpolate
from mpl_toolkits.mplot3d import Axes3D
import matplotlib as mpl
import matplotlib.cm as cm
import matplotlib.pyplot as plt

plt.style.use(['science', 'grid', 'muted'])

x0, y0 = np.mgrid[100:500:5j, 100:400:4j]
print(x0.shape, y0.shape)
z0 = np.array([636, 697, 624, 478, 450,
               698, 712, 630, 478, 420,
               680, 674, 598, 412, 400,
               662, 626, 552, 334, 310]).reshape((5, 4))
# 三次样条二维插值
f = interpolate.interp2d(x0, y0, z0, kind='cubic')
x1 = np.linspace(100, 500, 100)
y1 = np.linspace(100, 400, 100)
z1 = f(x1, y1)
x1, y1 = np.meshgrid(x1, y1)

plt.figure()

ax0 = plt.subplot(1, 2, 1, projection='3d')
surf0 = ax0.plot_surface(x0, y0, z0, rstride=2, cstride=2,
                         cmap=cm.coolwarm, linewidth=0.5, antialiased=True)
ax0.set_xlabel('x0')
ax0.set_ylabel('y0')
ax0.set_zlabel('z0')
plt.colorbar(surf0, shrink=0.5, aspect=5)

ax1 = plt.subplot(1, 2, 2, projection='3d')
surf1 = ax1.plot_surface(x1, y1, z1, rstride=2, cstride=2,
                         cmap=cm.coolwarm, linewidth=0.5, antialiased=True)
ax1.set_xlabel('x1')
ax1.set_ylabel('y1')
ax1.set_zlabel('z1')
plt.colorbar(surf1, shrink=0.5, aspect=5)

plt.suptitle('Interpolation-2D(The peak: {:3f})'.format(np.max(z1)))
plt.show()
=======
"""
插值方法：测量高程
"""

import numpy as np
from scipy import interpolate
from mpl_toolkits.mplot3d import Axes3D
import matplotlib as mpl
import matplotlib.cm as cm
import matplotlib.pyplot as plt

plt.style.use(['science', 'grid', 'muted'])

x0, y0 = np.mgrid[100:500:5j, 100:400:4j]
print(x0.shape, y0.shape)
z0 = np.array([636, 697, 624, 478, 450,
               698, 712, 630, 478, 420,
               680, 674, 598, 412, 400,
               662, 626, 552, 334, 310]).reshape((5, 4))
# 三次样条二维插值
f = interpolate.interp2d(x0, y0, z0, kind='cubic')
x1 = np.linspace(100, 500, 100)
y1 = np.linspace(100, 400, 100)
z1 = f(x1, y1)
x1, y1 = np.meshgrid(x1, y1)

plt.figure()

ax0 = plt.subplot(1, 2, 1, projection='3d')
surf0 = ax0.plot_surface(x0, y0, z0, rstride=2, cstride=2,
                         cmap=cm.coolwarm, linewidth=0.5, antialiased=True)
ax0.set_xlabel('x0')
ax0.set_ylabel('y0')
ax0.set_zlabel('z0')
plt.colorbar(surf0, shrink=0.5, aspect=5)

ax1 = plt.subplot(1, 2, 2, projection='3d')
surf1 = ax1.plot_surface(x1, y1, z1, rstride=2, cstride=2,
                         cmap=cm.coolwarm, linewidth=0.5, antialiased=True)
ax1.set_xlabel('x1')
ax1.set_ylabel('y1')
ax1.set_zlabel('z1')
plt.colorbar(surf1, shrink=0.5, aspect=5)

plt.suptitle('Interpolation-2D(The peak: {:3f})'.format(np.max(z1)))
plt.show()
>>>>>>> a66c8eec2c3bbe955d7da215f43ffffda9c7b6b5
